RockTypes = {
		"models/props_wasteland/rockcliff_cluster02a.mdl",
		"models/props_wasteland/rockcliff05f.mdl",
		"models/props_foliage/rock_coast02b.mdl",
		"models/cliffs/rocks_small01_veg.mdl",
		"models/cliffs/rocks_xlarge02_veg.mdl"
}

SavePos = {}


function SaveRockLocation ()



for k,value in pairs(RockTypes) do
	 
	for k,v in pairs(ents.FindByModel(value)) do
	print(k..": "..tostring(v:GetPos()))
	
	local pos = v:GetPos()
	print(pos[1].." "..pos[2].." "..pos[3])
	--table.insert(SavePos, {["model"] = tostring(v:GetModel()), ["pos"] = v:GetPos(), ["ang"] = v:GetAngles()})
	end
 end

 local data = util.TableToKeyValues(SavePos)
 Msg( "Saved Rock Positions"..data )
 
 --file.Write("usrp/rockdata.txt",data)
 end

 
 
 SpawnableRocks = {
	{"models/props_wasteland/rockcliff05f.mdl", -7160 , -2928 , -7907 ,  0 , -171 , 0 },
	{"models/props_foliage/rock_coast02b.mdl" , -7755 , -6220 , -8366 ,  0 ,   27 , 7 },
	{"models/Cliffs/rocks_small01_veg.mdl"    , -6862 , -9026 , -8223 , -3 ,  138 , 1 },
	{"models/Cliffs/rocks_xlarge02_veg.mdl"   , -7427 , -9737 , -8186 ,  0 ,  138 , 0 }
 
 }

 

 
 -- to spawn rocks, only start RockSpawner with lua_run or it will error
 function SpawnRock( model, pos, angle )
	local rock = ents.Create( "prop_physics" )
	rock:SetModel( model )
	rock:SetPos( pos )
	rock:SetAngles( angle ) 
	rock:Spawn()
	rock:PhysicsInit( SOLID_VPHYSICS )
	rock:SetMoveType( MOVETYPE_NONE )
	rock:SetSolid( SOLID_VPHYSICS )
end 



-- the function to fill the map with rocks
function RockSpawner()
		
	for i=1, #SpawnableRocks do
	
		local model = SpawnableRocks[i][1]
		local pos = Vector(SpawnableRocks[i][2],SpawnableRocks[i][3],SpawnableRocks[i][4])
		local angle = Angle(SpawnableRocks[i][5],SpawnableRocks[i][6],SpawnableRocks[i][7])	
		
		SpawnRock( model , pos , angle)

	end
	
end
hook.Add("InitPostEntity","usrp_rocks", RockSpawner)




-- function to remove rocks from the maps
 function RockRemover() 
	for i=1, #SpawnableRocks do
	 
		for k,v in pairs(ents.FindByModel(SpawnableRocks[i][1])) do
		print("Removing: "..tostring(v:GetModel()))
		v:Remove()
		 
		end
	end
end

-- to respawn the rocks incase they get fucked up or something
timer.Create("rockrespawn",3600,function() RockRemover() timer.Simple(0.1,RockSpawner) end)

-- model list to be blocked from the phygun being used on it
local StoolBlock = {
		
		"models/props/cs_militia/furnace01.mdl",
		"models/props_wasteland/rockcliff_cluster02a.mdl",
		"models/props_wasteland/rockcliff05f.mdl",
		"models/props_foliage/rock_coast02b.mdl",
		"models/cliffs/rocks_small01_veg.mdl",
		"models/cliffs/rocks_xlarge02_veg.mdl"
		
	}

	-- physgun and gravity gun blocking code
function ToolPickup(ply,ent) 
	for k,v in pairs(StoolBlock) do
		if(!ent:IsValid()) then 
		return end		
		if (ent:GetModel() == v ) then
		return false end 
	end	
end
	
hook.Add("PhysgunPickup", "PhysgunPickup", ToolPickup)
hook.Add("GravGunPunt", "GravGunPunt", ToolPickup)
hook.Add("GravGunPickupAllowed", "GravGunPickupAllowed", ToolPickup)
 

-- tool gun blocking code
function CanTool(ply, tr, toolgun)
	for k,v in pairs(StoolBlock) do
	
		if(tr.HitWorld) then return end
		ent = tr.Entity
		if(!ent:IsValid()) then return end
		if(ent:GetModel() == v )then
		return false
		end
		
	 end
	 
 end
 hook.Add("CanTool", "AsteriodCanTool", CanTool)
 
 
 
 -- function FakeRocket(ply)

-- hook.Add("Think","lol", function() ply:SetVelocity(Vector(0,0,1000))   end) 

-- ply:ChatPrint("You Just Got Punted!") 

-- timer.Simple(2,function() hook.Remove("Think","lol") ply:Kill() ply:ChatPrint("SCORE!") end)



-- end

	